//
//  WSSendMealTimeHeaderView.m
//  FD
//
//  Created by xiaofang wang on 2018/11/2.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "WSSendMealTimeHeaderView.h"
@interface WSSendMealTimeHeaderView()
/**1.当前城市Lb*/
@property (nonatomic, strong) UILabel *currentCityLb;
/**2定位城市Lb*/
@property (nonatomic, strong) UIButton *reLocationBtn;
/**背景*/
@property (nonatomic, strong) UIView *bgView;
@end

@implementation WSSendMealTimeHeaderView
#pragma mark - init

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
    }
    return self;
}

- (void)setupView {
    [self addSubview:self.bgView];
    self.backgroundColor = kMainLightGrayColor;
    
    [self.bgView addSubview:self.currentCityLb];
    [self.bgView addSubview:self.reLocationBtn];
}

- (void)layoutSubviews {
    [super layoutMarginsGuide];
    //被自己折磨死了
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.centerY.equalTo(self.mas_centerY);
        make.height.mas_equalTo(40);
    }];
    
    [self.currentCityLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView.mas_left).offset(15);
        make.centerY.equalTo(self.bgView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(200, 26));
    }];
    
    [self.reLocationBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView.mas_right).offset(-10);
        make.size.mas_equalTo(CGSizeMake(100, 22));
        make.centerY.equalTo(self.bgView.mas_centerY);
    }];
}

#pragma mark - getter
- (UIView *)bgView{
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}

- (UILabel *)currentCityLb {
    if (!_currentCityLb) {
        _currentCityLb = [UILabel new];
        _currentCityLb.text = @"当前城市: 杭州";
    }
    return _currentCityLb;
}
- (UIButton *)reLocationBtn {
    if (!_reLocationBtn) {
        _reLocationBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_reLocationBtn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
        [_reLocationBtn setTitle:@"  重新定位" forState:(UIControlStateNormal)];
        [_reLocationBtn setImage:[UIImage imageNamed:@"address"] forState:(UIControlStateNormal)];
        [_reLocationBtn addTarget:self action:@selector(clickReLocationBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _reLocationBtn;
}


#pragma mark - 点击事件
- (void)clickReLocationBtnAction:(UIButton *)btn
{
    FDLog(@"点击重新定位");
}



@end
